package com.zfc.freemyleft.freetrymyleftframe;

import android.Manifest;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.widget.Toast;

import com.freemyleft.left.left_app.launcher.LauncherDelegate;
import com.freemyleft.left.left_app.launcher.SignUpDelegate;
import com.freemyleft.left.left_app.mian.index.BottomDelegate;
import com.freemyleft.left.left_app.sign.ISignListenter;
import com.freemyleft.left.zapp.activitys.ProxyActivity;
import com.freemyleft.left.zapp.app.Left;
import com.freemyleft.left.zapp.calendar.librarycalendar.data.CalendarDate;
import com.freemyleft.left.zapp.delegates.LeftDelegate;
import com.freemyleft.left.zapp.ui.launcher.ILauncherListener;
import com.freemyleft.left.zapp.ui.launcher.OnLauncherFinshTag;


import cn.jpush.android.api.JPushInterface;
import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.PermissionUtils;
import permissions.dispatcher.RuntimePermissions;
import qiu.niorgai.StatusBarCompat;

@RuntimePermissions
public class ExampleActivity extends ProxyActivity implements
        ISignListenter, ILauncherListener {

    @Override
    @NeedsPermission({Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA
            , Manifest.permission.READ_EXTERNAL_STORAGE})
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //取消actionBar
        final ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        Left.getConfigurator().withActivity(this);
        StatusBarCompat.translucentStatusBar(this, true);
    }

    @Override
    public LeftDelegate setRootDelegate() {
        return new LauncherDelegate();
    }

    @Override
    public void onSignInSuccess() {
        Toast.makeText(this, "登录成功", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onSignUpSuccess() {
        //注册成功
        Toast.makeText(this, "注册成功", Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onPause() {
        super.onPause();
        JPushInterface.onPause(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        JPushInterface.onResume(this);
    }

    @Override
    public void onLauncherFinish(OnLauncherFinshTag tag) {
        switch (tag) {
            //如果登录了我们干什么
            case SIGNED:
                getSupportDelegate().startWithPop(new BottomDelegate(0));
                break;
            //没登录干什么这个地方跳转首页
            case NOT_SIGNED:
                getSupportDelegate().startWithPop(new SignUpDelegate());
                break;
            default:

        }
    }


}
